//
// Created by hjie on 23-5-15.
//

#include "redis_message_request.h"
#include "redis_message.h"
#include <cstddef>


RedisMessageRequest::RedisMessageRequest()
{
    m_message = nullptr;
}

RedisMessageRequest::~RedisMessageRequest()
{
    if (m_message)
    {
        delete m_message;
        m_message = nullptr;
    }
}

std::string RedisMessageRequest::GetData()
{
    std::string content;
    if (m_message && m_message->ComposeMessage(content))
    {
        return content;
    }
    else
    {
        content.clear();
        return content;
    }
}

bool RedisMessageRequest::ParseRequest(const std::string &command)
{
    m_message = RedisMessage::ParseCommand(command);
    return m_message == NULL ? false : true;
}

